<?php

namespace App\Admin\Controllers;

use App\Http\Controllers\Controller;
use App\Models\Arenacontest;
use App\Models\ArenacontestUser;
use App\Models\CityList;
use Encore\Admin\Controllers\HasResourceActions;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Layout\Content;
use Encore\Admin\Show;
use App\Models\WechatUser;
use App\Models\ArenacontestUserUser;

class ArenacontestRefundController extends Controller
{
    use HasResourceActions;

    private $name = '擂台赛交易';

    /**
     * Index interface.
     *
     * @param Content $content
     * @return Content
     */
    public function index(Content $content)
    {
        return $content
            ->header($this->name)
            ->description(trans('admin.list'))
            ->body($this->grid());
    }


    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        $grid = new Grid(new ArenacontestUser);
        $grid->disableCreateButton();
        //禁用行选择checkbox
        $grid->disableRowSelector();
        //禁用行操作列
        $grid->disableActions();
        //禁用行选择器
        $grid->disableColumnSelector();
        //设置分页选择器选项
        $grid->filter(function ($filter) {
            // 去掉默认的id过滤器
            $filter->disableIdFilter();
            // 在这里添加字段过滤器
            $filter->like('wxcode', '微信号');
            $filter->like('wxcode', '联系方式');
            $filter->like('wxcode', '订单编号');
            $filter->like('wxcode', '微信支付单号');
            $filter->equal('refundstate','退款状态')->select([
                1 => "退款申请中",
                2 => "已拒绝",
                3 => "退款中",
                4 => "已退款",
            ]);
        });
        $grid->arenacontest()->title('擂台赛');
        $grid->user()->name('用户');
        $grid->wxcode('微信号');
        $grid->contact('联系方式');
        $grid->ordersn('订单编号');
        $grid->price('金额');
        $grid->refundno('退款单号');
        $grid->refundstate('退款状态')->display(function ($status) {
            return ArenacontestUser::getRefundState($status);
        });
        $grid->model()->where('refundstate', '<>', 0)->orderBy('id', 'desc');
        $grid->model()->orderBy('id', 'desc');
        return $grid;
    }


}
